﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Automobile.service.BLL;
using Automobile.service.Model;


namespace Automobile.service.UI
{
    public partial class WareHoseEdit : System.Web.UI.Page
    {
        WareHoseBLL bll = new WareHoseBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"].ToString() != null)
                {
                    WareHoseLoad();
                }
            }
        }
        public void WareHoseLoad()
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            DataTable table = bll.GetWareHoseById(id);
            this.WareHose_Name.Value = table.Rows[0][1].ToString();
            this.WareHose_People.Value = table.Rows[0][2].ToString();
            this.WareHose_Phone.Value = table.Rows[0][3].ToString();
            this.WareHose_Address.Value = table.Rows[0][4].ToString();
            this.WareHose_Remark.Value = table.Rows[0][5].ToString();
        }

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            WareHose w = new WareHose();
            w.WareHose_Id = Convert.ToInt32(Request.QueryString["id"]);
            w.WareHose_Name = this.WareHose_Name.Value;
            w.WareHose_People = this.WareHose_People.Value;
            w.WareHose_Phone = this.WareHose_Phone.Value;
            w.WareHose_Address = this.WareHose_Address.Value;
            w.WareHose_Remark = this.WareHose_Remark.Value;
            if (bll.UpdWareHose(w) > 0)
            {
                Response.Write("<script>alert('修改成功！');</script>");
                Response.Redirect("WareHoseShow.aspx");
            }
            else
            {
                Response.Write("<script>alert('修改失败！')");
            }
        }
    }
}